/**
 * WidgetCreateCommand
 */

  function WidgetCreateCommand (page, widget, root, dataProvider) {
      this.page = page;
      this.widget = widget;
      this.root = root;
      this.dataProvider = dataProvider;
  };
  WidgetCreateCommand.prototype = {
      execute: function() {

      },
      undo: function() {
          // 执行删除元件操作
          this.dataProvider.removeWidget(this.page, this.widget, function (widgets){
              this.root.updateWidgets(widgets);
          }.bind(this), this.root, this.dataProvider, true);
      },
      redo: function() {
          // 执行增加元件操作
          var widget = this.widget;
          widget.type_display = widget.label;
          widget.form_history = true;
          widget.form_system = true;

          this.dataProvider.addWidgetToPage(this.page, widget, function (widgets){
              this.root.updateWidgets(widgets);
          }.bind(this), this.root, this.dataProvider, true);
      }
  };

  module.exports = WidgetCreateCommand;
